package com.study.config;

import com.study.binds.ContextResolver;
import com.study.interecptor.UrlInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/**
 * @author hupengming
 * @Title: 拦截器配置类
 * @Description:
 * @date 2021/3/18 11:19
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Autowired
    UrlInterceptor interceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(interceptor)
                .addPathPatterns("/mini/**");  // 拦截器拦截的路径
    }

    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
        resolvers.add(new ContextResolver());
    }
}
